export default {
  beforeRouteEnter(to, from, next) {
    const routerInfo = {
      // from: from.name ? from.path : '',
      route: to.name ? to.path : '',
      // keepAlive: to.meta.keepAlive
    }
    sessionStorage.setItem('routerInfo', JSON.stringify(routerInfo))
    next()
  },
  created() {
    // this.getRouterInfo()
  },
  activated() {
    // this.getRouterInfo()
  },
  methods: {
    getRouterInfo() {
      const routerInfoStr = sessionStorage.getItem('routerInfo')
      const routerInfo = routerInfoStr ? JSON.parse(routerInfoStr) : null
      if (routerInfo) {
        // 页面发生跳转的时候通知App
        JSCallNative('pageRouteName', {
          param: routerInfo,
          successCallBack: (data) => {
          },
          failedCallBack: (msg) => {
          }
        })
        // 本地存储的路由信息用完即删
        sessionStorage.removeItem('routerInfo')
      }
    }
  }
}
